home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Applications / ARTAbrot 1.0 / Menu_ARTAbrot.c < prev    next >
Text File  |  1993-08-18  |  5KB  |  177 lines

  1. /*  Menu_ARTAbrot                                 Handle a selection of the menu bar */
  2.  
  3. /* File name:  Menu_ARTAbrot.c   
  4.  Function:  This module calls the appropiate menu list 
  5.       handler routine. 
  6. History: 8/18/93 Original by George Warner
  7.    */
  8.  
  9.  
  10. #include "ComUtil_ARTAbrot.h"    /* Common */
  11.  
  12. #include "AB_Alert.h"    /* Alert */
  13. #include "About_ARTAbrot.h"    /* Modeless Dialog */
  14. #include "Enter_Coordinates.h"    /* Modeless Dialog */
  15. #include "ARTAbrot.h"    /* Window */
  16. #include "Menu_ARTAbrot.h"    /* This file */
  17.  
  18.  
  19. #pragma segment Menus
  20.  
  21.  
  22. /* Routine: Init_My_Menus */
  23. /* Purpose: Load in the menu lists and initialize the menubar */
  24.  
  25. void Init_My_Menus()
  26. {
  27.  
  28. ClearMenuBar();                                    /* Clear any old menu bars */
  29. /* This menu is the APPLE menu, used for About and desk accessories */
  30. Menu_Apple = GetMenu(Res_Menu_Apple);                /* Get the menu from the resource file */
  31. InsertMenu(Menu_Apple,0);                            /* Insert this menu into the menu bar */
  32.  
  33. AddResMenu(Menu_Apple,'DRVR');                        /* Add in DAs */
  34.  
  35. /* This menu is  File */
  36. Menu_File = GetMenu(Res_Menu_File);                /* Get the menu from the resource file */
  37. InsertMenu(Menu_File,0);                            /* Insert this menu into the menu bar */
  38.  
  39. /* This menu is  Commands */
  40. Menu_Commands = GetMenu(Res_Menu_Commands);        /* Get the menu from the resource file */
  41. InsertMenu(Menu_Commands,0);                        /* Insert this menu into the menu bar */
  42.  
  43.  
  44. DrawMenuBar();                                        /* Draw the menu bar */
  45. }
  46.  
  47. /* ======================================================= */
  48. void DoMenuApple(short theItem);                    /* Handle this menu list */
  49. void DoMenuFile(short theItem);                    /* Handle this menu list */
  50. void DoMenuCommands(short theItem);                /* Handle this menu list */
  51. /* ======================================================= */
  52.  
  53. /* Routine: Pre_Do_MenuListApple */
  54. /* Purpose: Handle all menu items in this list */
  55.  
  56. void DoMenuApple(short theItem)
  57. {
  58. Boolean    SkipProcessing;                            /* TRUE says skip processing */
  59. short    DNA;                                        /* For opening DAs */
  60. Str255    DAName;                                    /* For getting DA name */
  61. GrafPtr    SavePort;                                /* Save current port when opening DAs */
  62.  
  63. SkipProcessing = false;                            /* Set to not skip the processing of this menu item */
  64.  
  65. if (SkipProcessing == false)                        /* See if process the menu list */
  66.     {
  67.  
  68.     switch (theItem)                                /* Handle all commands in this menu list */
  69.         {
  70.         case MItem_About:
  71.             Add_UserEvent(UserEvent_Open_Window,Res_MD_About_ARTAbrot,0,0,NIL);/* Open a modeless dialog */
  72.             break;
  73.         default:                                /* allow other buttons, trap for debug */
  74.             GetPort(&SavePort);                    /* Save the current port */
  75.             GetItem(Menu_Apple, theItem, DAName);    /* Get the name of the DA selected */
  76.             DNA = OpenDeskAcc(DAName);                /* Open the DA selected */
  77.             SetPort(SavePort);                        /* Restore to the saved port */
  78.             break;                            /* end of otherwise */
  79.         }                                        /* end of switch */
  80.  
  81.     }                                            /* End of IF */
  82.  
  83. }
  84.  
  85. /* ======================================================= */
  86.  
  87. /* Routine: Pre_Do_MenuListFile */
  88. /* Purpose: Handle all menu items in this list */
  89.  
  90. void DoMenuFile(short theItem)
  91. {
  92. Boolean    SkipProcessing;                            /* TRUE says skip processing */
  93.  
  94. SkipProcessing = false;                            /* Set to not skip the processing of this menu item */
  95.  
  96. if (SkipProcessing == false)                        /* See if process the menu list */
  97.     {
  98.  
  99.     switch (theItem)                                /* Handle all commands in this menu list */
  100.         {
  101.         case MItem_Quit2:
  102.             doneFlag = true;
  103.             break;
  104.         default:                                /* allow other buttons, trap for debug */
  105.             break;                            /* end of otherwise */
  106.         }                                        /* end of switch */
  107.  
  108.     }                                            /* End of IF */
  109.  
  110. }
  111.  
  112. /* ======================================================= */
  113.  
  114. /* Routine: Pre_Do_MenuListCommands */
  115. /* Purpose: Handle all menu items in this list */
  116.  
  117. void DoMenuCommands(short theItem)
  118. {
  119. Boolean    SkipProcessing;                            /* TRUE says skip processing */
  120. Boolean    BoolHolder;                                /* For SystemEdit result */
  121.  
  122. SkipProcessing = false;                            /* Set to not skip the processing of this menu item */
  123.  
  124. if (SkipProcessing == false)                        /* See if process the menu list */
  125.     {
  126.  
  127.     BoolHolder = SystemEdit(theItem - 1);            /* Let the DA do the edit to itself */
  128.  
  129.     if  (BoolHolder == false)                        /* If not a DA then we get it */
  130.         {
  131.  
  132.         switch (theItem)                            /* Handle all commands in this menu list */
  133.             {
  134.             case MItem_Enter_Coordinat:
  135.                 Add_UserEvent(UserEvent_Open_Window,Res_MD_Enter_Coordinat,0,0,NIL);/* Open a modeless dialog */
  136.                 break;
  137.             case MItem_Display:
  138.                 Add_UserEvent(UserEvent_Open_Window,Res_W_ARTAbrot,0,0,NIL);/* Open a Window */
  139.                 break;
  140.             default:                            /* allow other buttons, trap for debug */
  141.                 break;                        /* end of otherwise */
  142.             }                                    /* end of switch */
  143.         }                                        /* End of IF */
  144.  
  145.     }                                            /* End of IF */
  146.  
  147. }
  148.  
  149. /* ======================================================= */
  150.  
  151. /* Routine: Handle_My_Menu */
  152. /* Purpose: Vector off to the appropiate menu list handler */
  153.  
  154. void Handle_My_Menu(short theMenu,short theItem)
  155. {
  156.  
  157. switch (theMenu)                                    /* Do selected menu list */
  158.     {
  159.     case Res_Menu_Apple:
  160.         DoMenuApple(theItem);                        /* Go handle this menu list */
  161.         break;
  162.     case Res_Menu_File:
  163.         DoMenuFile(theItem);                        /* Go handle this menu list */
  164.         break;
  165.     case Res_Menu_Commands:
  166.         DoMenuCommands(theItem);                    /* Go handle this menu list */
  167.         break;
  168.     default:                                    /* allow other buttons, trap for debug */
  169.         break;                                /* end of otherwise */
  170.     }                                            /* end of switch */
  171.  
  172. HiliteMenu(0);                                        /* Turn menu selection off */
  173. }
  174.  
  175. /* ======================================================= */
  176.  
  177.